﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtaisikudkandes_isik", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtaisikudkandesIsik))]
    public class MtaisikudkandesIsikSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtaisikudkandesIsik clazz;
        
        public MtaisikudkandesIsikSerializer(IMtaisikudkandesIsik clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.ReaId!=null) {
                Writer.WriteStartElement("rea_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ReaId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Ark!=null) {
                Writer.WriteStartElement("ark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.RolliId!=null) {
                Writer.WriteStartElement("rolli_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RolliId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsTyyp!=null) {
                Writer.WriteStartElement("as_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsTyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Osamaks!=null) {
                Writer.WriteStartElement("osamaks");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Osamaks))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Liignimi!=null) {
                Writer.WriteStartElement("liignimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liignimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Isikukood!=null) {
                Writer.WriteStartElement("isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Synnipaev!=null) {
                Writer.WriteStartElement("synnipaev");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Synnipaev))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Riik!=null) {
                Writer.WriteStartElement("riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Riik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ValisKood!=null) {
                Writer.WriteStartElement("valis_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValisKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Arinimi!=null) {
                Writer.WriteStartElement("arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Arinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ArkJur!=null) {
                Writer.WriteStartElement("ark_jur");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ArkJur))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Haldyks!=null) {
                Writer.WriteStartElement("haldyks");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Haldyks))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aadress!=null) {
                Writer.WriteStartElement("aadress");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.VolitusteKpv!=null) {
                Writer.WriteStartElement("volituste_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.VolitusteKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="rea_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>rea_id");
                }
                clazz.ReaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("rea_id")).Value;
            }
            if (Reader.LocalName=="ark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>ark");
                }
                clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
            }
            if (Reader.LocalName=="rolli_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>rolli_id");
                }
                clazz.RolliId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("rolli_id")).Value;
            }
            if (Reader.LocalName=="as_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>as_tyyp");
                }
                clazz.AsTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("as_tyyp")).Value;
            }
            if (Reader.LocalName=="osamaks") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>osamaks");
                }
                clazz.Osamaks = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("osamaks")).Value;
            }
            if (Reader.LocalName=="eesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>eesnimi");
                }
                clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            }
            if (Reader.LocalName=="liignimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>liignimi");
                }
                clazz.Liignimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liignimi")).Value;
            }
            if (Reader.LocalName=="isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            }
            if (Reader.LocalName=="synnipaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>synnipaev");
                }
                clazz.Synnipaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("synnipaev")).Value;
            }
            if (Reader.LocalName=="riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>riik");
                }
                clazz.Riik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("riik")).Value;
            }
            if (Reader.LocalName=="valis_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>valis_kood");
                }
                clazz.ValisKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valis_kood")).Value;
            }
            if (Reader.LocalName=="arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>arinimi");
                }
                clazz.Arinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("arinimi")).Value;
            }
            if (Reader.LocalName=="ark_jur") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>ark_jur");
                }
                clazz.ArkJur = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark_jur")).Value;
            }
            if (Reader.LocalName=="haldyks") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>haldyks");
                }
                clazz.Haldyks = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("haldyks")).Value;
            }
            if (Reader.LocalName=="aadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>aadress");
                }
                clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
            }
            if (Reader.LocalName=="volituste_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>volituste_kpv");
                }
                clazz.VolitusteKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("volituste_kpv")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtaisikudkandes_isik>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
